home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7526 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: [Help] I can't find my error.
  5. Date: 26 Feb 1996 03:51:09 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Feb25205109@qcd.lanl.gov>
  8. References: <4ggvgr$1b2@aurora.engr.LaTech.edu> <4gqutt$i1f@umbc9.umbc.edu>
  9. NNTP-Posting-Host: qcd.lanl.gov
  10. Mime-Version: 1.0
  11. Content-Type: text
  12. In-reply-to: schlein@umbc.edu's message of 25 Feb 1996 19:29:49 -0500
  13.  
  14. In article <4gqutt$i1f@umbc9.umbc.edu>
  15. schlein@umbc.edu (Jonas J. Schlein) writes:
  16.  
  17. JJS: |>     char name;    
  18. JJS: |>     int  age, next_age; 
  19. JJS: |> 
  20. JJS: |>     printf("%s\n","Please enter your name and age: ");
  21. JJS: |>     scanf("%s%d\n", &name, &age);
  22. JJS: 
  23. JJS: Why do you use %s when you clearly have 'name' declared as a single
  24. JJS: char. So either use %c in which case we'll assume you know a lot of people
  25. JJS: with 1 letter names /* OR */ make your declaration an array of acceptable
  26.  
  27. A single character name also overflows. %s adds a terminating '\0'.
  28.  
  29. Cheers
  30. Tanmoy
  31. --
  32. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  33. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  34. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  35. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  36. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  37. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  38.